[C#] SerialPort not taking input. It throws it back at me!

Posted by Mashew on Stack Overflow See other posts from Stack Overflow or by Mashew
Published on 2010-05-07T17:49:49Z Indexed on 2010/05/07 18:08 UTC
Read the original article Hit count: 272

Filed under:
|
|
|

When I try to write an AT command to my GSM modem, it does not seem to take the command. I have used PuTTY to check that the command words, it does. I have checked to see if the port is opening, it does.

What could I possibly be doing wrong?

NOTE: The "lol" part is for debugging purposes. ;3

           SerialPort sp = new SerialPort("COM3");
            sp.BaudRate = 9600;
            sp.DataBits = 8;
            sp.StopBits = StopBits.One;
            sp.Parity = Parity.None;
            sp.Open();
            if (sp.IsOpen == false)
            {
                sp.Open();
            }
            Thread.Sleep(1000);
            sp.WriteLine("AT+CMGF=1");
            Thread.Sleep(1000);
            string lol = sp.ReadExisting();
            sp.Close();
            return lol;

© Stack Overflow or respective owner

Related posts about c#

Related posts about serial-port